package com.cssw.fyzb.busi.util;

/**
 * 邀请码工具
 *
 * @author Feng Chen
 */
public abstract class CodeUtil {

    private CodeUtil() {

    }

    private static final Long BASE = 1000000000L;
    private static final Integer RADIX = 36;

    /**
     * 编码
     *
     * @param id
     * @return
     */
    public static String encode(Long id) {
        return Long.toString(BASE + id, RADIX).toUpperCase();
    }

    /**
     * 解码
     *
     * @param code
     * @return
     */
    public static Long decode(String code) {
        return Long.valueOf(code, RADIX) - BASE;
    }

    public static void main(String[] args) {
        Long decode = CodeUtil.decode("GJDHOB");
        System.out.println(decode);
        System.out.println(CodeUtil.encode(18283506l));
        //System.out.println(CodeUtil.decode(encode));
    }

}
